function [out,resEuler,p2_cup,logP2_cu] = NLSobjectFunc(thetaVec,setup)

if setup.objectFuncNum == 1
    [res,resEuler] = ResidualEquationProj(thetaVec,setup);
    p2_cup = NaN;
    logP2_cu = NaN;
elseif setup.objectFuncNum == 2
    [res,resEuler,p2_cup,logP2_cu] = ResidualEquationProjBondPrices(thetaVec,setup);
elseif setup.objectFuncNum == 3    
    [res,resEuler,p2_cup,logP2_cu] = ResidualEquationProjBondPricesReal(thetaVec,setup);
elseif setup.objectFuncNum == 4    
    [res,resEuler] = ResidualEquationProjExpectedControl(thetaVec,setup);    
    p2_cup = NaN;
    logP2_cu = NaN;
elseif setup.objectFuncNum == 5
    [res,resEuler] = ResidualEquationProjEquityPriceTEST(thetaVec,setup);
    p2_cup = NaN;
    logP2_cu = NaN;
end

if setup.optimizer <= 2
    out = res;
else
    out = res'*res;
end

end

